﻿using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Media;

namespace WPFTestSolution.Pages.Controls.TextBoxBases {
    
    /**
     * https://www.bilibili.com/video/BV1bV411A7Eq?p=38
     * 038-RichTextBox富文本(输入)框
     * https://www.wpfsoft.com/2023/08/28/1373.html
     */
    public partial class _38_RichTextBox_Page : Page {
        public _38_RichTextBox_Page() {
            InitializeComponent();
            this.Title = "038-RichTextBox富文本(输入)框";
        }

        private void _button_Confirm(object sender, RoutedEventArgs e) {
            TextRange textRange = new TextRange(this._richTextBox.Document.ContentStart, _richTextBox.Document.ContentEnd);
            MessageBox.Show(textRange.Text);
 
            Paragraph paragraph = new Paragraph();
            Run run = new Run($"当前时间：{DateTime.Now}"); //手动加换行
            run.Foreground = Brushes.Black;
            paragraph.Inlines.Add(run);
            _richTextBox.Document.Blocks.Add(paragraph);
        }
    }
}